from django.contrib import admin
from Blogs.models import Blog,Tag,ArticleForm,UserIP,Tool


# Register your models here.
class ContactBlog(admin.ModelAdmin):
    list_display = ('title','createtime', 'lasttime') # list
    search_fields = ['title',]
    fieldsets = (
        ['文章内容',{
            'fields':('title','content'),
        }],
		['额外添加',{
			'fields':('tags',),
		}],
    )
class ContactTag(admin.ModelAdmin):
	list_display=('name','color')
	search_fields=['name',]
	fieldsets=(
		['标签',{
			'fields':('name','color'),
		}],
	)
class ContactVisit(admin.ModelAdmin):
	list_display=('ip','ip_addr','blog_id','count')
class ContactTool(admin.ModelAdmin):
	list_display=('name','link')
class BlogAdmin(admin.ModelAdmin):
    list_display = ('title','createtime', 'lasttime')
    search_fields = ['title',]
    fieldsets = (
        ['文章内容',{
            'fields':('title','content'),
        }],
		['额外添加',{
			'fields':('tags',),
		}],
    )
    filter_horizontal=('tags',)
    form = ArticleForm
admin.site.register(Blog, BlogAdmin)
#admin.site.register(Blog,ContactBlog)
admin.site.register(Tag,ContactTag)
admin.site.register(UserIP,ContactVisit)
admin.site.register(Tool,ContactTool)